<!DOCTYPE html>
<html lang="zh">
<head>
    {{template "header" (ossUrl)}}
    <link href="/resource/ajax/libs/jasny/jasny-bootstrap.min.css" rel="stylesheet"/>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-8">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>站点配置信息</h5>
                </div>
                <div class="ibox-content">
                    <form method="get" class="form-horizontal" id="siteconfig" onsubmit="return submitHandler();">
                        <h4 class="form-header h4">基本配置</h4>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">站点名称</label>

                            <div class="col-sm-6">
                                <input type="text" name="sitename" class="form-control"
                                       value="{{.siteconfig.sitename}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">备案号</label>

                            <div class="col-sm-6">
                                <input type="text" name="beian" class="form-control" value="{{.siteconfig.beian}}">
                            </div>
                        </div>
                        <h4 class="form-header h4">SEO配置</h4>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">站点标题</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="site_title"
                                       value="{{.siteconfig.site_title}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">站点logo：</label>
                            <div class="col-sm-6 fileinput fileinput-new input-group"
                                 style="padding-right: 15px;padding-left: 15px;"
                                 data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput">
                                    <i class="glyphicon glyphicon-file fileinput-exists"></i>
                                    <span class="fileinput-filename">{{.siteconfig.sitethumb}}</span>
                                </div>
                                <input type="hidden" name="oldimage" value="{{.siteconfig.sitethumb}}">
                                <span class="input-group-addon btn btn-white btn-file">
                            <span class="fileinput-new">选择图片</span>
                            <span class="fileinput-exists">更改</span>
                            <input type="file" name="sitethumb">
                        </span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists"
                                   data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">关键词</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="keywords"
                                       value="{{.siteconfig.keywords}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">描述</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="description"
                                       value="{{.siteconfig.description}}">
                            </div>
                        </div>
                        <h4 class="form-header h4">邮件配置</h4>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">邮件发送方式</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="mail_type"
                                       value="{{.siteconfig.mail_type}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">SMTP服务器</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="mail_smtp_host"
                                       value="{{.siteconfig.mail_smtp_host}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">SMTP端口</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="mail_smtp_port"
                                       value="{{.siteconfig.mail_smtp_port}}" placeholder="25/465">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">SMTP用户名</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="mail_smtp_user"
                                       value="{{.siteconfig.mail_smtp_user}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">SMTP密码</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="mail_smtp_pass"
                                       value="{{.siteconfig.mail_smtp_pass}}">
                            </div>
                        </div>
{{/*                        <div class="form-group">*/}}
{{/*                            <label class="col-sm-2 control-label">SMTP验证方式</label>*/}}
{{/*                            <div class="col-sm-6">*/}}
{{/*                                <select class="form-control m-b" name="mail_verify_type">*/}}
{{/*                                    <option value="25">25</option>*/}}
{{/*                                    <option value="465">465</option>*/}}
{{/*                                </select>*/}}
{{/*                            </div>*/}}
{{/*                        </div>*/}}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">发件人邮箱</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="mail_from"
                                       value="{{.siteconfig.mail_from}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">测试邮箱</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="useremail"
                                       value="">
                            </div>
                            <div class="col-sm-2">
                                <button type="button" class="btn btn-primary" id="testemail">测试</button>
                            </div>
                        </div>
                        <h4 class="form-header h4"></h4>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary">保存内容</button>
                                <button type="button" class="btn btn-danger" onclick="closeItem()">关闭</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

{{template "footer" (ossUrl)}}
<script src="/resource/ajax/libs/jasny/jasny-bootstrap.min.js"></script>
<script type="text/javascript">
    var prefix = ctx + "system/siteconfig";

    function submitHandler() {
        var form = new FormData($("#siteconfig")[0]);
        $.operate.uploadsave(prefix + "/edit", form);
        // $.operate.save(prefix + "/edit", $('#siteconfig').serialize());
        return false; // 返回false，阻止跳转
    }

    $("#testemail").click(function () {
        var useremail = $("input[name='useremail']").val()
        if (useremail == "") {
            layer.msg("测试邮箱不能为空！！")
            return false
        }
        data = {
            useremail,
        }
        $.ajax({
            data: data,
            type: "POST",
            url: prefix + "/testemail", //图片上传出来的url，返回的是图片上传后的路径，http格式
            cache: false,
            dataType: "json",
            success: function (data) {//data是返回的hash,key之类的值，key是定义的文件名
                if (data.code === 0) {
                    layer.alert(data.msg)
                } else {
                    layer.alert("测试失败！！")
                }
            },
            error: function () {
                alert("测试失败！！");
            }
        });
        return false;
    })
</script>
</body>
</html>
